<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .active {
        color: red;
      }
    </style>
  </head>

  <body>
    <div id="app">
      <button
        v-for="tab in tabs"
        :key="tab"
        :class="{active: curCom === tab}"
        @click="curCom = tab"
      >
        {{ tab }}
      </button>
      <hr />
      <component :is="curCom"></component>
    </div>

    <script type="module">
      import { createApp } from "./lib/vue3.esm.browser.js";

      const app = createApp({
        data() {
          return {
            curCom: "Home",
            tabs: ["Home", "About", "Contact"],

            a: {
              template: `
                <h2>我的天</h2>
              `,
            },
          };
        },
      });

      app.component("Home", {
        template: `<h2>Home</h2>`,
      });

      app.component("About", {
        template: `<h2>About</h2>`,
      });

      app.component("Contact", {
        template: `<h2>Contact</h2>`,
      });

      app.mount("#app");
    </script>
  </body>
</html>
